let express = require('express');
let router = express.Router();

router.get('/', function (req, res, next) {
    req.app.db.query("select name as text, value, keysValues as types, exception from dic order by keysValues, value", [], function (err, results, fields) {
        if (err) {
            res.json({"success": false, "message": global.databaseErr, "detail": err});
            return;
        }

        let dics = {};
        for (let i = 0; i < results.length; i++) {
            if (dics[results[i].types] === undefined) {
                dics[results[i].types] = []
            }

            dics[results[i].types].push(results[i]);
        }

        res.json({"success": true, "data": dics});
    });
});



module.exports = router;